@extends('admin.layout.main')
@section('content')
    <!-- iCheck for checkboxes and radio inputs -->
    <link rel="stylesheet" href="{{asset('/adminlte/plugins/iCheck/all.css')}}">
    <section class="content-header">
      <h1>
        二级代理列表
      </h1>
      <ol class="breadcrumb">
        <li><a href="javascript:void(0)"><i class="fa fa-dashboard"></i> 游戏代理</a></li>
      </ol>
    </section>
    <section class="content">
        <!-- Small boxes (Stat box) -->
        <div class="row">
            <div class="col-lg-12 col-xs-6">
                <div class="box">
                    <div class="box-header with-border">
                        <div class="row">
                            <div class="col-sm-10">
                                
                            </div>
                        </div> 
                    </div>
                    
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered table-hover" id="user-list">
                            <thead>
                                <tr>
                                    <th style="width: 50px"><a style="cursor:pointer" class="all_check">全选</a></th>
                                    <th>电话</th>
                                    <th>姓名</th>
                                    <th>通过时间</th>
                                    <th>代理地区</th>
                                    <th>房卡数量</th>
                                    <th>发展玩家数量</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody> 
                                @foreach($agents as $agent)
                                    <tr id="{{$agent->id}}">
                                        <td>
                                            <input type="checkbox" name="checkbox_member" class="checkbox_member" user-id="{{$agent->id}}">
                                        </td>
                                        <td>{{$agent->mobile}}</td>
                                        <td>{{$agent->realname}}</td>
                                        <td>{{ date('Y-m-d H:i', $agent->pass_time) }}</td>
                                        <td>{{$agent->address}}</td>
                                        <td>{{$agent->user()->gems}}</td>
                                        <td>{{$agent->userNum()}}</td>
                                        <td>
                                            <a href="javascript:void(0)" class="group-users"><i class="fa fa-fw fa-users"></i>玩家</a>
                                            <a href="/admin/agent/assign_log/{{$agent->id}}?type=2"><i class="fa fa-fw fa-shopping-cart"></i>接收记录</a>
                                            <a href="/admin/agent/send_log/{{$agent->id}}?type=3"><i class="fa fa-fw fa-send"></i>分配记录</a>
                                            <a href="javascript:void(0)" class="open-circle" @if($agent->open_circle == 1) style="color:#0ba00b" @else style="color:#de2710" @endif><i class="fa fa-fw fa-wechat"></i>亲友圈</a>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                        {{$agents->links()}}
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- datepicker -->
    <script src="{{asset('/adminlte/plugins/datepicker/bootstrap-datepicker.js')}}"></script>
    <!-- iCheck 1.0.1 -->
    <script src="{{asset('/adminlte/plugins/iCheck/icheck.min.js')}}"></script>
    <script type="text/javascript">
        $(function () {
            $('#user-list').DataTable({
              "paging": false,
              "lengthChange": false,
              "searching": false,
              "info": false,
              "autoWidth": true,
              "columns": [
                {"orderable": false},
                {"orderable": false},
                {"orderable": true},
                {"orderable": true},
                {"orderable": true},
                {"orderable": true},
                {"orderable": true},
                {"orderable": true}
              ]
            });
        });

        $('.all_check').click(function(){
            $('.checkbox_member').click();
        });

        $('#datepicker').datepicker({
          autoclose: true,
          endDate: new Date()
        });

        $('.open-circle').click(function(){
            var aid = $(this).parents('tr').attr('id');
            dialog_params('/admin/agent/open_circle/'+aid, '会员亲友圈');
        });

        $('.group-users').click(function(){
            var aid = $(this).parents('tr').attr('id');
            dialog_group('/admin/agent/dvlp_users/'+aid, '发展玩家');
        });

    </script>
@endsection      